#!/bin/bash

###
### Program: timemachine
### File:    tm-onsite-archive.sh
### Version: 2.0
### Owner:   raptus ag
### Author:  Florian S.
### Purpose:
###
### Archiving of latest backup on local backup server
###
###

#
# standard stuff
#

if ! test "$#" -eq 1
then
    echo "Usage: $0 <config-file>"
    exit 1
fi

SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
OLDDIR="`pwd`"
cd $SCRIPTPATH

CONFIGFILE="$1"
if ! test -f "$CONFIGFILE"
then
    echo "ERROR: Cannot find config file $CONFIGFILE"
    exit 1
fi

source "../config/defaults.conf"
source "$CONFIGFILE"
source "functions/logging.inc.sh"

#
# logfile stuff
#

log "======================================================================="
./tm-onsite.sh $CONFIGFILE

if [ "$RETENTION_DAILY" -eq "0" ] && [ "$RETENTION_WEEKLY" -eq "0" ] && [ "$RETENTION_MONTHLY" -eq "0" ] && [ "$RETENTION_YEARLY" -eq "0" ] ; then
    log "No archiving desired."
else
    ./tm-archiver.sh $CONFIGFILE
fi

log "======================================================================="

# eof
